$(function () {
  var app = {
    openId: GetRequest().openId,
    hostSever: getServerHost(),
    havePrize: '/api/longtaitou/prize',
    init: function () {
      app.xijiLinkfun()
      app.getMyPrize();
    },
    xijiLinkfun: function () {
      $('.xijiLink').click(function () {
        location.href = "http://m.xiji.com/wap/newuserrecommend.html";
      })
    },
    getMyPrize: function () {
      $.get(app.hostSever + app.havePrize, {
        openId: app.openId
      }).done(function (rp) {

        if (200 == rp.code) {
          $('.loading').hide();
          var prizeType = ['.noprize', '.upan', '.liuliang', '.xiji']
          if (!Boolean(rp.res)) {
            $(prizeType[0]).show();
            return;
          }
          if (1 == rp.res.type) {
            $('.pName').text(rp.res.name)
            $('.pPhone').text(rp.res.mobile)
            $('.pAddr').text(rp.res.address)
          } else if (2 == rp.res.type) {
            $('.pPhone').text(rp.res.mobile)
          }
          $(prizeType[rp.res.type]).show();
        }
      }).fail(function (rp) {})
    }
  }
  window.onload = function () {
    preventMove();
    app.init();
  }
});